using UnityEngine;

/// <summary>
/// MonoBehaviour对象池实现
/// </summary>
/// <typeparam name="T">MonoBehaviour类型</typeparam>
public class MonoBehaviourPool<T> : AbstractPool<T> where T : MonoBehaviour
{
    public MonoBehaviourPool(IPoolFactory<T> factory, int initialSize = 10, int maxSize = 100) 
        : base(factory, initialSize, maxSize)
    {
    }
    
    protected override void OnObjectSpawned(T obj)
    {
        base.OnObjectSpawned(obj);
        obj.gameObject.SetActive(true);
    }
    
    protected override void OnObjectReturned(T obj)
    {
        base.OnObjectReturned(obj);
        obj.gameObject.SetActive(false);
    }
}
